.markdown-body {
  position: relative;
  // padding: 0 30px 0;
  color: @text-color;
  white-space: pre-wrap;

  [data-content-id] {
    margin-bottom: 12px;
  }
  :global {
    [data-page-number]:not(:only-child):not(.hidden-page) {
      &:not(:empty):has(> :not(.hidden)):after {
        display: block;
        margin: 8px 0 20px;
        color: @text-gray-color;
        font-size: 12px;
        text-align: center;
        border-bottom: 1px solid #eee;
        content: '[\7b2c'attr(data-page-number) '\9875]';
        user-select: none;
      }
    }
    [data-testid='virtuoso-item-list'] {
      padding-right: 30px;
      padding-left: 30px;
    }
  }

  a {
    color: @primary-color;
  }

  p {
    margin-bottom: 12px;
    color: inherit;
  }

  ol,
  ul {
    margin-left: 40px;
    padding-left: 0;
    font-size: 0;

    li {
      font-size: 14px;
    }
  }

  table {
    &,
    & td,
    & th {
      border: 1px solid #999;
    }

    th,
    td {
      padding: 8px;

      p:last-child {
        margin-bottom: 0;
      }
    }
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    color: inherit;
    font-weight: bold;
  }

  h1 {
    font-size: 24px;
  }
  h2 {
    font-size: 20px;
  }
  h3 {
    font-size: 18px;
  }
  h4,
  h5,
  h6 {
    font-size: 14px;
  }

  :global {
    .active {
      color: @primary-color;
      h1,
      h2,
      h3,
      h4,
      h5,
      h6 {
        position: relative;
        &::before {
          position: absolute;
          top: 50%;
          left: -26px;
          color: #769df0;
          font-size: 14px;
          line-height: 1;
          transform: translateY(-50%);
        }
      }
      h1::before {
        content: 'H1';
      }
      h2::before {
        content: 'H2';
      }
      h3::before {
        content: 'H3';
      }
      h4::before {
        font-size: 12px;
        content: 'H4';
      }
      h5::before {
        font-size: 12px;
        content: 'H5';
      }
      h6::before {
        font-size: 12px;
        content: 'H6';
      }

      .no-content {
        color: @primary-color !important;
      }

      table {
        border: 1px solid @primary-color;
      }

      table {
        &,
        th,
        td {
          color: @text-color;
          border-color: @primary-color;
        }

        tr .active {
          background-color: rgba(17, 163, 95, 0.25);
        }
      }

      .split-table-line {
        border-color: @primary-color;
      }

      .image-text {
        color: @primary-color;
      }
    }

    .copy-handle {
      position: absolute;
      top: 0;
      left: -20px;
      display: none;
      cursor: pointer;
    }

    .content-container {
      position: relative;

      &:hover {
        &::before {
          position: absolute;
          top: 0;
          bottom: 0;
          left: -20px;
          width: 20px;
          content: '';
        }

        .copy-handle {
          display: block;
        }
      }
    }

    .image-wrapper {
      &:not(.has-text) {
        img {
          border: 1px solid transparent;
        }

        &.active {
          img {
            border-color: #bd8d1c;
          }

          &.stamp {
            img {
              border-color: #ad581a;
            }
          }
        }
      }

      &.has-text {
        .image-wrapper-border {
          display: inline-block;
          max-width: 100%;
          padding: 12px;
          border: 1px solid #e1e4eb;

          img {
            border: 0;
          }
        }

        &.active {
          .image-wrapper-border {
            border-color: #bd8d1c;
          }

          &.stamp .image-wrapper-border {
            border-color: #ad581a;
          }
        }
      }

      .chart-table {
        margin-top: 12px;

        table {
          width: 100%;
        }
      }
    }

    .table-wrapper {
      position: relative;
    }

    .split-table-line {
      position: absolute;
      right: -20px;
      left: 0;
      height: 1px;
      background-color: #fff;
      border-bottom: 1px dashed #999;

      .split-table-line-number {
        position: absolute;
        top: -48px;
        right: 0;
        color: @text-gray-color;
        font-size: 12px;
        line-height: 16px;
        text-align: center;

        span {
          display: block;
        }
      }
    }

    .formula-item {
      &:not(:last-child) {
        margin-bottom: 12px;
      }

      .copy-handle {
        top: calc(50% - 10px);
      }
    }

    img {
      max-width: 100%;
      max-height: 100vh;
    }

    .no-content {
      font-size: 12px;

      &:not(.active) {
        color: @text-gray-color;
      }
    }

    mjx-merror {
      padding: 2px 4px;
      color: rgba(211, 73, 73, 0.75);
      background-color: rgba(224, 224, 36, 0.3);
    }
  }
}

.editor {
  display: none;
  border: none !important;
  visibility: hidden;
  :global {
    .vditor-toolbar {
      display: none;
    }
    .vditor-ir pre.vditor-reset {
      height: auto;
      padding: 4px !important;
      background-color: #e9f0ffaa !important;
      &:empty {
        display: none;
      }
    }
    .vditor-reset {
      font-size: inherit;
    }
    .vditor-reset h1,
    .vditor-reset h2,
    .vditor-reset h3,
    .vditor-reset h4,
    .vditor-reset h5,
    .vditor-reset h6 {
      margin: 0;
      padding-bottom: 0;
      border-bottom: none;
    }
    .vditor-reset h1 {
      font-size: 2em;
    }
    .vditor-reset h2 {
      font-size: 1.5em;
    }
    .vditor-reset h3 {
      font-size: 1.17em;
    }
    .vditor-reset h4 {
      font-size: 1em;
    }
    .vditor-reset h5 {
      font-size: 0.83em;
    }
    .vditor-reset h6 {
      font-size: 0.67em;
    }
    .vditor-content {
      // min-height: 48px;
      // padding-bottom: 16px;
      min-height: 0;
      padding-bottom: 0;
    }
    .vditor-reset table td,
    .vditor-reset table th {
      white-space: normal;
    }
  }
}

.markdownBodyEditMode {
  // :global {
  //   .active {
  //     color: inherit !important;
  //   }
  // }
  .editor {
    visibility: visible;
  }
}

.editMode {
  display: flex !important;
  visibility: visible;
  .editor {
    display: flex !important;
    visibility: visible;
  }
}

.question-item {
  margin-bottom: 0 !important;

  &:not(:first-child) {
    padding-top: 8px;
    border-top: 1px solid #eee;
  }

  .question-type {
    margin: 0 -12px 8px;
    padding: 0 12px;
    color: #757a85;
    line-height: 32px;
    background-color: rgba(242, 244, 247, 0.8);
  }

  .line-container {
    display: flex;

    .line-label {
      flex: 0 0 60px;
      color: @text-gray-color;
    }
  }

  .question-image {
    display: inline-block;
    padding: 0 16px;
    border: 1px solid @border-color-base;
    border-radius: 2px;
    cursor: pointer;
    transition: 0.3;

    &:hover,
    &:global(.active) {
      color: @primary-color;
      border-color: @primary-color;
    }

    &:not(:last-child) {
      margin-right: 8px;
    }
  }
}
